package com.dope_lh.glide;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

public class MainActivity extends AppCompatActivity {

    private ImageView imageView;
    private RequestOptions requestOptions;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn = (Button) findViewById(R.id.btn);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loadImage();
            }
        });
        imageView = (ImageView) findViewById(R.id.iv);

        requestOptions = new RequestOptions().placeholder(R.drawable.a1_share);
    }

    private void loadImage() {
        String url = "http://guolin.tech/book.png";
        Glide.with(this).load(url).apply(requestOptions).into(imageView);
    }
}
